print('#############迭代，dict类型迭代#############')
dict_type = {'a': 98, 'b': 80, 'c': 78, 'd': "db", "e": "abaj", 9: "fh"}
print(dict_type)
print('#############默认情况下，dict迭代的是key。d.keys()可以省略#############')
for k in dict_type.keys():
    print(k)
for k in dict_type.values():
    print(k)
for k, v in dict_type.items():
    print(k, v)
print('#############迭代，String类型迭代#############')
for ch in 'abcdef':
    print(ch)
print('#############迭代，判断类型是否能迭代#############')
from collections.abc import Iterable

print("字符串类型：", isinstance("def", Iterable))
print("dict类型：", isinstance(dict_type, Iterable))
print("int类型：", isinstance(123, Iterable))
print('#############Python内置的enumerate函数可以把一个list|tuple|str|dict变成索引-元素对#############')
list1 = ["list1", 'list2', 'list3']
tuple1 = ('tuple1', 'tuple2', 'tuple3')
str1 = "abcd"
dict1 = {"tom": 18, "jack": 17}
for i, value in enumerate(list1):
    print(i, value)
for i, value in enumerate(tuple1):
    print(i, value)
for i, value in enumerate(str1):
    print(i, value)
for i, value in enumerate(dict1):
    print(i, value)
print('#############for循环里，同时引用了两个变量#############')
for x, y in [(1, 1), (2, 4), (3, 9)]:
    print(x, y)
